Returns the value of a DICOM element
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As DicomDataSet
Dim element As DicomElement
Dim defaultValue As T
Dim value As T
value = instance.GetValue(Of T)(element, defaultValue) |
Parameters
- element
- an item in the data set
- defaultValue
- a value of type T that is returned if the actual value cannot be retrieved.
Type Parameters
- T
- specifies the type of the value to return
Return Value
a value of type T that is the value of the DICOM element
Example
This example will insert several elements into a DICOM data set, and then retrieve the values
Visual Basic | Copy Code |
---|
'''
Private Sub DicomDataSet_GetValueExample()
Dim sMsg As String
' ***************************************************
' *** First
' *** Create some elements and set the values
' ***************************************************
Dim ds As DicomDataSet = New DicomDataSet()
ds.InsertElementAndSetValue(DicomTag.HighBit, 15)
' This is how you check to see if the element got added -- for simplicity, we only check the first time
MessageBox.Show(ds.InsertElementAndSetValueResult.ToString())
Dim names As String() = {"ORIGINAL", "PRIMARY"}
ds.InsertElementAndSetValue(DicomTag.ImageType, names)
ds.InsertElementAndSetValue(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb)
ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, Now)
ds.InsertElementAndSetValue(DicomTag.PatientName, "John^Smith")
' ***************************************************
' *** Second
' *** Retrieve the element values
' ***************************************************
' Get an int value of an element by specifying a tag
Dim highbit As Integer = ds.GetValue(Of Integer)(DicomTag.HighBit, 0)
' This is how you check to see if the element value was successfully retrieved
MessageBox.Show(ds.GetValueResult.ToString())
' Get a list of strings value of an element by specifying a tag
Dim imageType As List(Of String) = ds.GetValue(Of List(Of String))(DicomTag.ImageType, Nothing)
sMsg = String.Format("Result: {0}" & Constants.vbLf & "Values:", ds.GetValueResult)
For Each s As String In imageType
sMsg = sMsg & Constants.vbLf & s
Next s
MessageBox.Show(sMsg)
' Get an enumeration value of an element by specifying a tag
Dim p As DicomImagePhotometricInterpretationType = ds.GetValue(Of DicomImagePhotometricInterpretationType)(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb)
' Get value of an element by specifying the element
Dim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PatientName, False)
Dim name As String = ds.GetValue(Of String)(element, Nothing)
MessageBox.Show(name)
' Another overload
Dim defaultDateTime As DateTime = New DateTime()
Dim dateTime As DateTime = ds.GetValue(Of DateTime)(Nothing, True, DicomTag.PatientBirthDate, defaultDateTime)
MessageBox.Show(dateTime.ToString())
End Sub |
C# | Copy Code |
---|
///
private void DicomDataSet_GetValueExample()
{
string sMsg;
// ***************************************************
// *** First
// *** Create some elements and set the values
// ***************************************************
DicomDataSet ds = new DicomDataSet();
ds.InsertElementAndSetValue(DicomTag.HighBit, 15);
// This is how you check to see if the element got added -- for simplicity, we only check the first time
MessageBox.Show(ds.InsertElementAndSetValueResult.ToString());
string[] names = { "ORIGINAL", "PRIMARY" };
ds.InsertElementAndSetValue(DicomTag.ImageType, names);
ds.InsertElementAndSetValue(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb);
ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, DateTime.Now);
ds.InsertElementAndSetValue(DicomTag.PatientName, "John^Smith");
// ***************************************************
// *** Second
// *** Retrieve the element values
// ***************************************************
// Get an int value of an element by specifying a tag
int highbit = ds.GetValue<int>(DicomTag.HighBit, 0);
// This is how you check to see if the element value was successfully retrieved
MessageBox.Show(ds.GetValueResult.ToString());
// Get a list of strings value of an element by specifying a tag
List<string> imageType = ds.GetValue<List<string>>(DicomTag.ImageType, null);
sMsg = string.Format("Result: {0}\nValues:", ds.GetValueResult);
foreach (string s in imageType)
{
sMsg = sMsg + "\n" + s;
}
MessageBox.Show(sMsg);
// Get an enumeration value of an element by specifying a tag
DicomImagePhotometricInterpretationType p = ds.GetValue<DicomImagePhotometricInterpretationType>(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb);
// Get value of an element by specifying the element
DicomElement element = ds.FindFirstElement(null, DicomTag.PatientName, false);
string name = ds.GetValue<string>(element, null);
MessageBox.Show(name);
// Another overload
DateTime defaultDateTime = new DateTime();
DateTime dateTime = ds.GetValue<DateTime>(null, true, DicomTag.PatientBirthDate, defaultDateTime);
MessageBox.Show(dateTime.ToString());
} |
SilverlightCSharp | Copy Code |
---|
private void DicomDataSet_GetValueExample()
{
string sMsg;
// ***************************************************
// *** First
// *** Create some elements and set the values
// ***************************************************
DicomDataSet ds = new DicomDataSet();
ds.InsertElementAndSetValue(DicomTag.HighBit, 15);
// This is how you check to see if the element got added -- for simplicity, we only check the first time
Debug.WriteLine(ds.InsertElementAndSetValueResult.ToString());
string[] names = { "ORIGINAL", "PRIMARY" };
ds.InsertElementAndSetValue(DicomTag.ImageType, names);
ds.InsertElementAndSetValue(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb);
ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, DateTime.Now);
ds.InsertElementAndSetValue(DicomTag.PatientName, "John^Smith");
// ***************************************************
// *** Second
// *** Retrieve the element values
// ***************************************************
// Get an int value of an element by specifying a tag
int highbit = ds.GetValue<int>(DicomTag.HighBit, 0);
// This is how you check to see if the element value was successfully retrieved
Debug.WriteLine(ds.GetValueResult.ToString());
// Get a list of strings value of an element by specifying a tag
List<string> imageType = ds.GetValue<List<string>>(DicomTag.ImageType, null);
sMsg = string.Format("Result: {0}\nValues:", ds.GetValueResult);
foreach (string s in imageType)
{
sMsg = sMsg + "\n" + s;
}
Debug.WriteLine(sMsg);
// Get an enumeration value of an element by specifying a tag
DicomImagePhotometricInterpretationType p = ds.GetValue<DicomImagePhotometricInterpretationType>(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb);
// Get value of an element by specifying the element
DicomElement element = ds.FindFirstElement(null, DicomTag.PatientName, false);
string name = ds.GetValue<string>(element, null);
Debug.WriteLine(name);
// Another overload
DateTime defaultDateTime = new DateTime();
DateTime dateTime = ds.GetValue<DateTime>(null, true, DicomTag.PatientBirthDate, defaultDateTime);
Debug.WriteLine(dateTime.ToString());
} |
SilverlightVB | Copy Code |
---|
Private Sub DicomDataSet_GetValueExample()
Dim sMsg As String
' ***************************************************
' *** First
' *** Create some elements and set the values
' ***************************************************
Dim ds As DicomDataSet = New DicomDataSet()
ds.InsertElementAndSetValue(DicomTag.HighBit, 15)
' This is how you check to see if the element got added -- for simplicity, we only check the first time
Debug.WriteLine(ds.InsertElementAndSetValueResult.ToString())
Dim names As String() = { "ORIGINAL", "PRIMARY" }
ds.InsertElementAndSetValue(DicomTag.ImageType, names)
ds.InsertElementAndSetValue(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb)
ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, System.DateTime.Now)
ds.InsertElementAndSetValue(DicomTag.PatientName, "John^Smith")
' ***************************************************
' *** Second
' *** Retrieve the element values
' ***************************************************
' Get an int value of an element by specifying a tag
Dim highbit As Integer = ds.GetValue(Of Integer)(DicomTag.HighBit, 0)
' This is how you check to see if the element value was successfully retrieved
Debug.WriteLine(ds.GetValueResult.ToString())
' Get a list of strings value of an element by specifying a tag
Dim imageType As List(Of String) = ds.GetValue(Of List(Of String))(DicomTag.ImageType, Nothing)
sMsg = String.Format("Result: {0}" & Constants.vbLf & "Values:", ds.GetValueResult)
For Each s As String In imageType
sMsg = sMsg & Constants.vbLf & s
Next s
Debug.WriteLine(sMsg)
' Get an enumeration value of an element by specifying a tag
Dim p As DicomImagePhotometricInterpretationType = ds.GetValue(Of DicomImagePhotometricInterpretationType)(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb)
' Get value of an element by specifying the element
Dim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PatientName, False)
Dim name As String = ds.GetValue(Of String)(element, Nothing)
Debug.WriteLine(name)
' Another overload
Dim defaultDateTime As DateTime = New DateTime()
Dim dateTime As DateTime = ds.GetValue(Of DateTime)(Nothing, True, DicomTag.PatientBirthDate, defaultDateTime)
Debug.WriteLine(dateTime.ToString())
End Sub |
Remarks
Requirements
Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)
See Also